xend: Rename device backend value when xm save/migrate
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 7 Aug 2009 16:22:04 +0000 (17:22 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 7 Aug 2009 16:22:04 +0000 (17:22 +0100)
The Xend has a problem that it often fails to restore/migrate
a PV domain whose device backends are partly a driver domain.

Because a checkpoint of the PV domain has device backend value as
domain id, you can restore/migrate the PV domain only when a driver
domain is the same id as device backend value in the checkpoint.

I attached a patch to fix it by renaming device backend value in a
checkpoint from domain id to domain name when xm save/migrate.

This patch doesn't rename device backend value if the value is 0,
which is Domain-0, so the checkpoint format is compatible if you use
only Domain-0 as device backend.

Signed-off-by: Rikiya Ayukawa <ayukawa.rikiya@jp.fujitsu.com>
tools/python/xen/xend/XendCheckpoint.py

index 3952846d4fc74f845a89351deae3f4e710edfe95..146437c486f655a0c2fad09ccfb6fdac98cd387e 100644 (file)
@@ -66,6 +66,8 @@ def insert_after(list, pred, value):
 
 
 def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1):
+    from xen.xend import XendDomain
+
     try:
         if not os.path.isdir("/var/lib/xen"):
             os.makedirs("/var/lib/xen")
@@ -80,6 +82,18 @@ def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1):
     if node > -1:
         insert_after(sxprep,'vcpus',['node', str(node)])
 
+    for device_sxp in sxp.children(sxprep, 'device'):
+        backend = sxp.child(device_sxp[1], 'backend')
+        if backend == None:
+            continue
+        bkdominfo = XendDomain.instance().domain_lookup_nr(backend[1])
+        if bkdominfo == None:
+            raise XendError("Could not find backend: %s" % backend[1])
+        if bkdominfo.getDomid() == XendDomain.DOM0_ID:
+            # Skip for compatibility of checkpoint data format
+            continue
+        backend[1] = bkdominfo.getName()
+        
     config = sxp.to_string(sxprep)
 
     domain_name = dominfo.getName()